<template>
  <div class="container">
    <!-- 数据大屏展示内容区域 -->
    <div class="screen" ref="screen">
      <div class="top">
        <Top />
      </div>
      <div class="bottom">
        <div class="left">
          <!-- 游客比例 -->
          <Tourist class="tourist" />
          <!-- 性别比例 -->
          <Sex class="sex" />
          <!-- 年龄比例 -->
          <Age class="age" />
        </div>
        <div class="center">
          <Map class="map" />
          <Line class="line" />
        </div>
        <div class="right">
          <Rank class="rank"></Rank>
          <Year class="year"></Year>
          <Couter class="couter"></Couter>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue'
import Top from './components/top/index.vue'
import Tourist from './components/tourist/index.vue'
import Sex from './components/sex/index.vue'
import Age from './components/age/index.vue'
import Map from './components/map/index.vue'
import Line from './components/line/index.vue'
import Rank from './components/rank/index.vue'
import Year from './components/year/index.vue'
import Couter from './components/couter/index.vue'
// 获取数据大屏展示内容的DOM元素
let screen = ref()

onMounted(() => {
  screen.value.style.transform = `scale(${getScate()}) translate(-50%,-50%)`
})

// 定义大屏缩放比例
const getScate = (w = 1920, h = 1080) => {
  const ww = window.innerWidth / w
  const wh = window.innerHeight / h
  return ww < wh ? ww : wh
}

//监听视口的变化
window.onresize = () => {
  screen.value.style.transform = `scale(${getScate()}) translate(-50%,-50%)`
}
</script>

<style scoped lang="scss">
.container {
  width: 100vw;
  height: 100vh;
  background: url(./images/bg.png) no-repeat;
  background-size: cover;

  .screen {
    width: 1920px;
    height: 1080px;
    position: fixed;
    left: 50%;
    top: 50%;
    transform-origin: left top;
  }

  .top {
    width: 100%;
    height: 40px;
  }

  .bottom {
    display: flex;

    .left {
      flex: 1;
      height: 1040px;
      display: flex;
      flex-direction: column;
      .tourist {
        flex: 1.2;
      }
      .sex {
        flex: 1;
      }
      .age {
        flex: 1;
      }
    }

    .center {
      flex: 1.5;
      display: flex;
      flex-direction: column;
      height: 1040px;
      .map {
        flex: 2.5;
      }
      .line {
        flex: 1;
      }
    }

    .right {
      flex: 1;
      display: flex;
      flex-direction: column;
      height: 1010px;
      .rank {
        flex: 1;
      }
      .year {
        flex: 1;
      }
      .couter {
        flex: 1;
      }
    }
  }
}
</style>
